<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Inviter
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: Controller.php 2010-07-02 19:54 mirlan $
 * @author     Mirlan
 */

/**
 * @category   Application_Extensions
 * @package    Inviter
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 */

class Inviter_Widget_HomeInviterController extends Engine_Content_Widget_Abstract
{
  protected $_errors = array(), $_success;

  public function init(){
    $this->view->headTranslate(array(
      'INVITER_Failed!, please check your contacts and try again.',
      'INVITER_Failed! Please check and try again later.',
    ));
  }

  public function indexAction()
  {
    if(!Engine_Api::_()->authorization()->isAllowed('inviter', null, 'use'))
    {
      return $this->setNoRender();
    }

    $settings = Engine_Api::_()->getApi('settings', 'core');
    $this->view->facebookKey = $settings->getSetting('inviter.facebook.consumer.key', false);
    $this->view->twitterKey = $settings->getSetting('inviter.twitter.consumer.key', false);
    $this->view->linkedinKey = $settings->getSetting('inviter.linkedin.consumer.key', false);
    $this->view->gmailKey = $settings->getSetting('inviter.gmail.consumer.key', false);

    $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
    $session = new Zend_Session_Namespace('contacts');
    $session->unsetAll();

    $this->view->form = $form = new Inviter_Form_Widget_Import();

    if ($viewer->getIdentity())
    {
      $this->view->form_write = $form_write = new Inviter_Form_Widget_Write();
    }
  }
}